package com.tul.exercise.base.clazz.base.eg3;

import static com.tul.exercise.base.utils.Print.print;

/**
 * @author tul
 * 《java编程思想》 14章 示例3:类的初始化触发
 *
 */
public class ClassInitilization {

    public static void main(String[] args) throws Exception{
        // 不会触发初始化操作
        Class initable = Initable.class;
        print("After creating Initable ref");

        // 触发初始化操作
        print(Initable.staticFinal);

        // 触发初始化操作
        print(Initable.staticFinal2);

        try {
            // 触发初始化操作
            Class initable3 = Class.forName("Initable3");
            print("After creating Initable3 ref");
            print(Initable3.staticNonFinal);
        } catch (ClassNotFoundException e) {
            print("ClassNotFoundException:" + e.getMessage());
        }

    }
}
